package com.liuchao.maven.practice.rabbitmq.ps;

import com.liuchao.maven.practice.rabbitmq.RabbitMQUtil;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * @Description:
 * @Auther: Liu Chao
 * @Date: 2018/8/11 19:50
 */
public class Publish {

    public static final String EXCHANGE_NAME = "test_exchange_fanout";

    public static void main(String[] args) throws IOException, TimeoutException {

        Connection connection = RabbitMQUtil.getConnection();
        Channel channel = connection.createChannel();
        channel.exchangeDeclare(EXCHANGE_NAME, "fanout");
        String msg = "hello exchange fanout";
        channel.basicPublish(EXCHANGE_NAME, "", null, msg.getBytes());

        System.out.println("send: " + msg);
        channel.close();
        connection.close();
    }
}
